$(function () {
    $.ajax({
        type: 'get',
        url: "/contact-us/info/listAll",
        //contentType: 'application/json;charset=utf-8',
        success: function(data){    //请求成功时的回调函数
            if(data.code == "1"){
                var userList = data.data;
                for(var i = 0;i<userList.length;i++){
                    var user = userList[i];
                    //行
                    var str = $("<tr></tr>");
                    var str1 = $("<tr id='a"+i+"' style=\"display: none;\"></tr>");
                    //列
                    var std = $("<th scope=\"row\"></th>");
                    var std1 = $("<td><div></div></td>");
                    var std2 = $("<td> <button class='btn btn-default btn-rounded' type='button' onclick='zhanshi("+i+")'><i class='icon-layers'></i> 详细信息</button></td>");
                    str.append(std.clone().text(i));
                    str.append(std1.clone().text(user.name));
                    str.append(std1.clone().text(user.email));
                    str.append(std1.clone().text(user.createTime));
                    str.append(std1.clone().text(user.subject));
                    str.append(std2.clone());
                    str.appendTo($("#tabletext"));
                    str1.append(std1.clone().text(user.message));
                    str1.appendTo($("#tabletext"));

                }
                //window.location.href="/main-page";
            }else{
                alert(data.msg + data.data);
            }
        },
    });
});
function zhanshi(id) {
    var id1="a"+id;
    var obj = document.getElementById(id1);
    if(obj.style.display==""){
        obj.style.display="none";
    }else{
        obj.style.display="";
    }

}